package com.demo.hadoop;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

/**
 * 对输入的日志进行分割
 *
 * @author lee9213@163.com
 * @version 1.0
 * @date 2017/3/22 14:32
 */
public class AccessProcessMap extends MapReduceBase implements Mapper<LongWritable, Text, Text, Text> {

    @Override
    public void map(LongWritable key, Text value, OutputCollector<Text, Text> outputCollector, Reporter reporter) throws IOException {
        String[] input_fields = value.toString().split(" ");
        outputCollector.collect(new Text(input_fields[3]), new Text("1"));
    }
}
